home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / workbench / directoryopus4 / dopus4_src / dopus_print / doprint.c < prev    next >
C/C++ Source or Header  |  2000-03-11  |  21KB  |  571 lines

  1. /*
  2.  
  3. Directory Opus 4
  4. Original GPL release version 4.12
  5. Copyright 1993-2000 Jonathan Potter
  6.  
  7. This program is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU General Public License
  9. as published by the Free Software Foundation; either version 2
  10. of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. All users of Directory Opus 4 (including versions distributed
  22. under the GPL) are entitled to upgrade to the latest version of
  23. Directory Opus version 5 at a reduced price. Please see
  24. http://www.gpsoft.com.au for more information.
  25.  
  26. The release of Directory Opus 4 under the GPL in NO WAY affects
  27. the existing commercial status of Directory Opus 5.
  28.  
  29. */
  30.  
  31. #include "print.h"
  32. #include <proto/powerpacker.h>
  33.  
  34. struct PrintHandle {
  35.     int filehandle;
  36.     struct MsgPort *port;
  37.     struct IOStdReq *ioreq;
  38.     char *filename;
  39.     int current_line;
  40.     int current_page;
  41.     int paper_lines;
  42.     int paper_width;
  43.     int paper_height;
  44.     char buffer[1024];
  45.     char datebuf[12];
  46.     char fileoutput;
  47.     struct RequesterBase *reqbase;
  48.     struct RastPort *req_rp;
  49.     int total_pos;
  50.     int filesize;
  51.     int progress_y;
  52.     int req_width;
  53. };
  54.  
  55. int do_header_footer(struct PrintHandle *,PrintData *,int);
  56. int do_printstyle(struct PrintHandle *,int,int);
  57. int print_str(struct PrintHandle *,char *,int);
  58. int printer_command(struct RequesterBase *,struct PrintHandle *,char *);
  59. int check_print_abort(struct RequesterBase *);
  60. void show_progress(struct PrintHandle *);
  61. void print_status(struct PrintHandle *handle,char *text,int y);
  62.  
  63. char
  64.     *esc_styles[]={
  65.         "\x1b[0m",         /* STYLE_NORMAL       */
  66.         "\x1b[1m",         /* STYLE_BOLD         */
  67.         "\x1b[3m",         /* STYLE_ITALICS      */
  68.         "\x1b[4m",         /* STYLE_UNDERLINED   */
  69.         "\x1b[4\"z",       /* STYLE_DOUBLESTRIKE */
  70.         "\x1b[6\"z"};      /* STYLE_SHADOW       */
  71.  
  72. printfile(reqbase,filename,printdata,requester)
  73. struct RequesterBase *reqbase;
  74. char *filename;
  75. PrintData *printdata;
  76. struct Requester *requester;
  77. {
  78.     int fileh=0,a,lastspace=-1,margin,filesize,ret=0;
  79.     int buffersize,size,pos=0,bufpos=0;
  80.     char *buffer=NULL,*linebuffer,*marginbuf;
  81.     struct PrintHandle *handle;
  82.     struct DOpusRemember *memkey=NULL;
  83.     struct DOpusDateTime *datetime;
  84.     struct TextFont *font;
  85.  
  86.     FOREVER {
  87.         if (CheckExist(filename,&filesize)<0) break;
  88.         if (!(check_error(reqbase,string_table[STR_UNABLE_TO_OPEN_FILE],0)))
  89.             return(0);
  90.     }
  91.  
  92.     if (!(datetime=LAllocRemember(&memkey,sizeof(struct DOpusDateTime),MEMF_CLEAR)) ||
  93.         !(handle=LAllocRemember(&memkey,sizeof(struct PrintHandle),MEMF_CLEAR))) {
  94.         LFreeRemember(&memkey);
  95.         return(0);
  96.     }
  97.  
  98.     handle->paper_lines=(printdata->bottom_margin-printdata->top_margin)+1;
  99.     handle->paper_height=handle->paper_lines;
  100.     if (printdata->headfoot[FOOTER].headfoot_flags) handle->paper_lines-=2;
  101.     handle->paper_width=(printdata->right_margin-printdata->left_margin)+1;
  102.     handle->filename=BaseName(filename);
  103.     handle->reqbase=reqbase;
  104.  
  105.     if ((margin=printdata->left_margin-1)>0) {
  106.         if (!(marginbuf=LAllocRemember(&memkey,margin+1,MEMF_CLEAR)))
  107.             goto ENDPRINT;
  108.         for (a=0;a<margin;a++) marginbuf[a]=' ';
  109.     }
  110.     if (!(linebuffer=LAllocRemember(&memkey,(handle->paper_width*2)+4,MEMF_CLEAR)))
  111.         goto ENDPRINT;
  112.  
  113.     if (Request(requester,reqbase->rb_window)) {
  114.         font=reqbase->rb_window->RPort->Font;
  115.         handle->req_rp=requester->ReqLayer->rp;
  116.         handle->req_width=requester->Width;
  117.         Do3DBox(handle->req_rp,2,1,
  118.             requester->Width-4,requester->Height-2,
  119.             reqbase->rb_shine,reqbase->rb_shadow);
  120.         SetAPen(handle->req_rp,reqbase->rb_fg);
  121.         SetBPen(handle->req_rp,reqbase->rb_bg);
  122.         SetDrMd(handle->req_rp,JAM2);
  123.         SetFont(handle->req_rp,font);
  124.         handle->progress_y=font->tf_YSize*3;
  125.         print_status(handle,
  126.             (printdata->print_flags&PRINTFLAG_FILE && printdata->output_file[0])?
  127.                 string_table[STR_CREATING_FILE]:
  128.             string_table[STR_OPENING_PRINTER],
  129.             handle->progress_y);
  130.     }
  131.  
  132.     if (printdata->print_flags&PRINTFLAG_FILE && printdata->output_file[0]) {
  133.         FOREVER {
  134.             if ((handle->filehandle=Open(printdata->output_file,
  135.                 (a=(CheckExist(printdata->output_file,NULL))?MODE_READWRITE:MODE_NEWFILE)))) {
  136.                 if (a==MODE_READWRITE) Seek(handle->filehandle,0,OFFSET_END);
  137.                 handle->fileoutput=1;
  138.                 break;
  139.             }
  140.             if (!(check_error(reqbase,string_table[STR_UNABLE_TO_OPEN_OUTPUT],0)))
  141.                 goto ENDPRINT;
  142.         }
  143.     }
  144.     else {
  145.         struct Preferences *prefs;
  146.  
  147.         if (!(handle->port=LCreatePort(NULL,0)) ||
  148.             !(handle->ioreq=(struct IOStdReq *)LCreateExtIO(handle->port,sizeof(struct IOStdReq))))
  149.             goto ENDPRINT;
  150.  
  151.         FOREVER {
  152.             if (!(OpenDevice("printer.device",0,(struct IORequest *)handle->ioreq,0))) break;
  153.             if (!(check_error(reqbase,string_table[STR_UNABLE_TO_OPEN_PRINTER],0))) {
  154.                 LDeleteExtIO((struct IORequest *)handle->ioreq);
  155.                 handle->ioreq=NULL;
  156.                 goto ENDPRINT;
  157.             }
  158.         }
  159.         prefs=&(((struct PrinterData *)handle->ioreq->io_Device)->pd_Preferences);
  160.  
  161.         prefs->PrintLeftMargin=1;
  162.         prefs->PrintRightMargin=printdata->right_margin;
  163.  
  164.         prefs->PaperLength=printdata->bottom_margin+2;
  165.  
  166.         if (printdata->print_pitch==PITCH_PICA) prefs->PrintPitch=PICA;
  167.         else if (printdata->print_pitch==PITCH_FINE) prefs->PrintPitch=FINE;
  168.         else if (printdata->print_pitch==PITCH_ELITE) prefs->PrintPitch=ELITE;
  169.  
  170.         if (printdata->text_quality==QUALITY_DRAFT) prefs->PrintQuality=DRAFT;
  171.         else prefs->PrintQuality=LETTER;
  172.  
  173.         if (!(printer_command(reqbase,handle,"\033#1"))) goto ENDPRINT;
  174.     }
  175.  
  176.     if (handle->req_rp) {
  177.         SetAPen(handle->req_rp,reqbase->rb_bg);
  178.         RectFill(handle->req_rp,2,1,
  179.             requester->Width-3,requester->Height-2);
  180.         print_status(handle,string_table[STR_LOADING_FILE],handle->progress_y);
  181.     }
  182.  
  183.     if (PPBase) {
  184.         FOREVER {
  185.             if ((a = ppLoadData(filename,DECR_POINTER,MEMF_CLEAR,(UBYTE **)&buffer,&buffersize,NULL))==PP_PASSERR) {
  186.                 if (!(check_error(reqbase,string_table[STR_INCORRECT_PASSWORD],0)))
  187.                     goto ENDPRINT;
  188.             }
  189.             else break;
  190.         }
  191.         size=buffersize;
  192.         filesize=buffersize;
  193.     }
  194.  
  195.     if (!buffer) {
  196.         buffersize=filesize;
  197.         while (!(buffer=AllocMem(buffersize,MEMF_CLEAR))) {
  198.             buffersize/=2;
  199.             if (buffersize==0) goto ENDPRINT;
  200.         }
  201.         if (!(fileh=Open(filename,MODE_OLDFILE))) goto ENDPRINT;
  202.         size=Read(fileh,buffer,buffersize);
  203.     }
  204.  
  205.     handle->filesize=filesize;
  206.  
  207.     if (handle->req_rp) {
  208.         print_status(handle,
  209.             string_table[STR_PRINTING_FILE],
  210.             font->tf_YSize);
  211.         print_status(handle,
  212.             string_table[STR_PRESS_ESCAPE],
  213.             (font->tf_YSize*5));
  214.         show_progress(handle);
  215.     }
  216.  
  217.     DateStamp(&datetime->dat_Stamp);
  218.     datetime->dat_Format=FORMAT_DOS;
  219.     datetime->dat_StrDate=handle->datebuf;
  220.     StampToStr(datetime);
  221.  
  222.     FOREVER {
  223.         if (bufpos>=size && (!fileh || (size=Read(fileh,buffer,buffersize))<1)) {
  224.             if (pos>0) {
  225.                 if ((marginbuf && !(print_str(handle,marginbuf,-1))) ||
  226.                     !(print_str(handle,linebuffer,pos))) goto ENDPRINT;
  227.             }
  228.             if (handle->current_line<=handle->paper_lines) {
  229.                 if (handle->current_line==0) {
  230.                     for (a=1;a<printdata->top_margin;a++)
  231.                         if (!(print_str(handle,"\n",1))) goto ENDPRINT;
  232.                     ++handle->current_page;
  233.                 }
  234.                 if (printdata->headfoot[FOOTER].headfoot_flags) {
  235.                     for (;handle->current_line<handle->paper_lines;handle->current_line++)
  236.                         if (!(print_str(handle,"\n",1))) goto ENDPRINT;
  237.                     if (!(do_header_footer(handle,printdata,FOOTER)))
  238.                         break;
  239.                 }
  240.             }
  241.             if (handle->current_line>0 &&
  242.                 printdata->print_flags&PRINTFLAG_EJECT &&
  243.                 !(print_str(handle,"\f",1))) break;
  244.             break;
  245.         }
  246.         bufpos=0;
  247.         while (bufpos<size) {
  248.             if (check_print_abort(reqbase)) goto ENDPRINT;
  249.             if (handle->current_line<handle->paper_lines) {
  250.                 if (handle->current_line==0) {
  251.                     for (a=1;a<printdata->top_margin;a++)
  252.                         if (!(print_str(handle,"\n",1))) goto ENDPRINT;
  253.                     ++handle->current_page;
  254.                 }
  255.                 if (handle->current_line==0 &&
  256.                     printdata->headfoot[HEADER].headfoot_flags) {
  257.                     if (!(do_header_footer(handle,printdata,HEADER))) goto ENDPRINT;
  258.                     handle->current_line+=2;
  259.                 }
  260.                 else {
  261.                     while (bufpos<size && handle->current_line<handle->paper_lines) {
  262.                         if (check_print_abort(reqbase)) goto ENDPRINT;
  263.  
  264.                         switch (buffer[bufpos]) {
  265.  
  266.                             /* Tab character; pad buffer with spaces to next tab stop */
  267.                             case '\t':
  268.                                 if ((pos%printdata->tab_size)==0) a=printdata->tab_size;
  269.                                 else a=(((pos/printdata->tab_size)+1)*printdata->tab_size)-pos;
  270.                                 while (pos<=handle->paper_width && (a--))
  271.                                     linebuffer[(pos++)]=' ';
  272.                                 lastspace=pos-1;
  273.                                 break;
  274.  
  275.                             /* Form feed */
  276.                             case '\f':
  277.                                 if (pos>0) {
  278.                                     if (marginbuf && !(print_str(handle,marginbuf,margin)))
  279.                                         goto ENDPRINT;
  280.                                     if (!(print_str(handle,linebuffer,pos))) goto ENDPRINT;
  281.                                 }
  282.                                 if (printdata->headfoot[FOOTER].headfoot_flags) {
  283.                                     for (;handle->current_line<handle->paper_lines;handle->current_line++)
  284.                                         if (!(print_str(handle,"\n",1))) goto ENDPRINT;
  285.                                 }
  286.                                 else {
  287.                                     handle->current_line=0;
  288.                                     if (!(print_str(handle,"\f",1))) goto ENDPRINT;
  289.                                 }
  290.                                 lastspace=-1; pos=0;
  291.                                 show_progress(handle);
  292.                                 break;
  293.  
  294.                             /* New line */
  295.                             case '\n':
  296.  
  297.                                 /* Only store newline character in buffer if we are not
  298.                                    on the last line of the page */
  299.  
  300.                                 if (handle->current_line<handle->paper_height-1 || handle->fileoutput)
  301.                                     linebuffer[pos++]='\n';
  302.  
  303.                                 if (marginbuf && !(print_str(handle,marginbuf,margin)))
  304.                                     goto ENDPRINT;
  305.                                 if (!(print_str(handle,linebuffer,pos))) goto ENDPRINT;
  306.                                 lastspace=-1; pos=0; ++handle->current_line;
  307.                                 show_progress(handle);
  308.                                 break;
  309.  
  310.                             default:
  311.                                 if (isspace(buffer[bufpos])) lastspace=pos;
  312.                                 else if (ispunct(buffer[bufpos])) {
  313.                                     if (lastspace==-1 || pos>lastspace+8) lastspace=pos;
  314.                                 }
  315.                                 linebuffer[pos++]=buffer[bufpos];
  316.                                 if (pos>handle->paper_width) {
  317.                                     if (marginbuf && !(print_str(handle,marginbuf,margin)))
  318.                                         goto ENDPRINT;
  319.                                     if (lastspace>0 && lastspace<pos) {
  320.                                         a=lastspace+1;
  321.                                         if (!(print_str(handle,linebuffer,a-(isspace(linebuffer[lastspace])?1:0))))
  322.                                             goto ENDPRINT;
  323.                                         pos-=a;
  324.                                         if (pos>0) CopyMem(&linebuffer[a],linebuffer,pos);
  325.                                     }
  326.                                     else {
  327.                                         if (!(print_str(handle,linebuffer,handle->paper_width)))
  328.                                             goto ENDPRINT;
  329.                                         linebuffer[0]=linebuffer[handle->paper_width];
  330.                                         pos=1;
  331.                                     }
  332.  
  333.                                     if (handle->current_line<handle->paper_height-1 || handle->fileoutput) {
  334.                                         if (!(print_str(handle,"\n",1))) goto ENDPRINT;
  335.                                     }
  336.  
  337.                                     if (pos<0) {
  338.                                         pos=0;
  339.                                         show_progress(handle);
  340.                                     }
  341.                                     lastspace=-1;
  342.                                     for (a=0;a<pos;a++) {
  343.                                         if (isspace(linebuffer[a])) lastspace=a;
  344.                                         else if (ispunct(linebuffer[a])) {
  345.                                             if (lastspace==-1 || pos>lastspace+8) lastspace=a;
  346.                                         }
  347.                                     }
  348.                                     ++handle->current_line;
  349.                                 }
  350.                                 break;
  351.                         }
  352.                         ++bufpos;
  353.                         ++handle->total_pos;
  354.                     }
  355.                 }
  356.             }
  357.             else {
  358.                 if (!(do_header_footer(handle,printdata,FOOTER))) goto ENDPRINT;
  359.                 handle->current_line=0;
  360.                 if (!(print_str(handle,"\f",1))) goto ENDPRINT;
  361.             }
  362.         }
  363.     }
  364.  
  365.     ret=1;
  366.  
  367. ENDPRINT:
  368.     if (buffer) FreeMem(buffer,buffersize);
  369.     if (fileh) Close(fileh);
  370.     if (handle->filehandle) Close(handle->filehandle);
  371.     if (handle->ioreq) {
  372.         CloseDevice((struct IORequest *)handle->ioreq);
  373.         LDeleteExtIO((struct IORequest *)handle->ioreq);
  374.     }
  375.     if (handle->port) LDeletePort(handle->port);
  376.     if (handle->req_rp) EndRequest(requester,reqbase->rb_window);
  377.     LFreeRemember(&memkey);
  378.     return(ret);
  379. }
  380.  
  381. do_header_footer(handle,printdata,type)
  382. struct PrintHandle *handle;
  383. PrintData *printdata;
  384. int type;
  385. {
  386.     int a,b;
  387.     int leftoffset;
  388.     int len;
  389.  
  390.     if (printdata->headfoot[type].headfoot_flags) {
  391.         leftoffset=printdata->left_margin-1;
  392.  
  393.         if (!(do_printstyle(handle,printdata->headfoot[type].text_style,1)))
  394.             return(0);
  395.  
  396.         for (a=0;a<sizeof(handle->buffer);a++) handle->buffer[a]=' ';
  397.  
  398.         if (printdata->headfoot[type].headfoot_flags&HEADFOOTFLAG_DATE)
  399.             CopyMem(handle->datebuf,&handle->buffer[leftoffset+1],9);
  400.  
  401.         if (printdata->headfoot[type].headfoot_flags&HEADFOOTFLAG_TITLE) {
  402.             char titlebuf[40];
  403.  
  404.             if (printdata->headfoot[type].headfoot_title[0])
  405.                 strcpy(titlebuf,printdata->headfoot[type].headfoot_title);
  406.             else strcpy(titlebuf,handle->filename);
  407.  
  408.             if ((a=strlen(titlebuf))>handle->paper_width) {
  409.                 a=handle->paper_width;
  410.                 b=0;
  411.             }
  412.             else b=(handle->paper_width-a)/2;
  413.             b+=leftoffset;
  414.             CopyMem(titlebuf,&handle->buffer[b],a);
  415.         }
  416.  
  417.         if (printdata->headfoot[type].headfoot_flags&HEADFOOTFLAG_PAGE) {
  418.             char pagebuf[20];
  419.  
  420.             lsprintf(pagebuf,"%s %ld",string_table[STR_PAGE],handle->current_page);
  421.  
  422.             a=leftoffset+(handle->paper_width-strlen(pagebuf)-1);
  423.             CopyMem(pagebuf,&handle->buffer[a],strlen(pagebuf));
  424.         }
  425.  
  426.         if (type==FOOTER && !(print_str(handle,"\n",-1))) return(0);
  427.  
  428.         len=leftoffset+handle->paper_width;
  429.  
  430.         if (type==HEADER || handle->fileoutput) {
  431.             handle->buffer[leftoffset+handle->paper_width]='\n';
  432.             len+=1;
  433.         }
  434.  
  435.         if (!(print_str(handle,handle->buffer,len))) return(0);
  436.  
  437.         if (type==HEADER && !(print_str(handle,"\n",-1))) return(0);
  438.  
  439.         if (!(do_printstyle(handle,printdata->headfoot[type].text_style,0)))
  440.             return(0);
  441.     }
  442.     return(1);
  443. }
  444.  
  445. do_printstyle(handle,style,turnon)
  446. struct PrintHandle *handle;
  447. int style,turnon;
  448. {
  449.     int a=1;
  450.  
  451.     if (handle->ioreq) {
  452.         if (turnon) a=print_str(handle,esc_styles[style],-1);
  453.         else {
  454.             if ((a=print_str(handle,esc_styles[0],-1))) {
  455.                 if (style==STYLE_DOUBLESTRIKE)
  456.                     a=print_str(handle,DOUBLESTRIKE_OFF,-1);
  457.                 else if (style==STYLE_SHADOW)
  458.                     a=print_str(handle,SHADOW_OFF,-1);
  459.             }
  460.         }
  461.     }
  462.     return(a);
  463. }
  464.  
  465. print_str(handle,string,stlen)
  466. struct PrintHandle *handle;
  467. char *string;
  468. int stlen;
  469. {
  470.     int len,success,seek;
  471.  
  472.     if ((len=stlen)==-1) {
  473.         if ((len=strlen(string))>handle->paper_width)
  474.             len=handle->paper_width;
  475.     }
  476.  
  477.     if (len<1) return(1);
  478.  
  479.     FOREVER {
  480.         seek=0;
  481.         if (handle->filehandle) {
  482.             success=((seek=Write(handle->filehandle,string,len))==len);
  483.         }
  484.         else if (handle->ioreq) {
  485.             handle->ioreq->io_Length=len;
  486.             handle->ioreq->io_Data=(APTR)string;
  487.             handle->ioreq->io_Command=CMD_WRITE;
  488.             success=(!(DoIO((struct IORequest *)handle->ioreq)));
  489.         }
  490.         else return(0);
  491.         if (success) return(1);
  492.         if (!(check_error(handle->reqbase,string_table[STR_PRINT_ERROR],0))) return(0);
  493.         if (seek>0) Seek(handle->filehandle,-seek,0);
  494.     }
  495. }
  496.  
  497. printer_command(reqbase,handle,command)
  498. struct RequesterBase *reqbase;
  499. struct PrintHandle *handle;
  500. char *command;
  501. {
  502.     handle->ioreq->io_Length=-1;
  503.     handle->ioreq->io_Data=(APTR)command;
  504.     handle->ioreq->io_Command=CMD_WRITE;
  505.  
  506.     FOREVER {
  507.         if (!(DoIO((struct IORequest *)handle->ioreq))) break;
  508.         if (!(check_error(reqbase,string_table[STR_UNABLE_TO_OPEN_PRINTER],0)))
  509.             return(0);
  510.     }
  511.     return(1);
  512. }
  513.  
  514. check_print_abort(reqbase)
  515. struct RequesterBase *reqbase;
  516. {
  517.     struct IntuiMessage *msg;
  518.     int abort=0;
  519.  
  520.     while (msg=(struct IntuiMessage *)GetMsg(reqbase->rb_window->UserPort)) {
  521.         if (msg->Class==IDCMP_VANILLAKEY && msg->Code==0x1b) {
  522.             if (check_error(reqbase,string_table[STR_REALLY_ABORT],1))
  523.                 abort=1;
  524.         }
  525.         ReplyMsg((struct Message *)msg);
  526.     }
  527.     return(abort);
  528. }
  529.  
  530. void show_progress(handle)
  531. struct PrintHandle *handle;
  532. {
  533.     float percent;
  534.     char buf[20];
  535.  
  536.     if (!handle->total_pos || !handle->filesize) percent=0;
  537.     else percent=((float)((float)handle->total_pos/(float)handle->filesize))*100;
  538.  
  539.     lsprintf(buf,"%3ld%% %s ",(int)percent,string_table[STR_COMPLETE]);
  540.     print_status(handle,buf,handle->progress_y);
  541. }
  542.  
  543. void print_status(handle,text,y)
  544. struct PrintHandle *handle;
  545. char *text;
  546. int y;
  547. {
  548.     int x;
  549.     struct TextFont *font;
  550.     struct RequesterBase *reqbase;
  551.  
  552.     reqbase=handle->reqbase;
  553.     font=handle->req_rp->Font;
  554.     x=(handle->req_width-((strlen(text))*font->tf_XSize))/2;
  555.     if (x>1) {
  556.         SetAPen(handle->req_rp,reqbase->rb_bg);
  557.         RectFill(handle->req_rp,
  558.             2,y,
  559.             x,y+font->tf_YSize);
  560.     }
  561.     SetAPen(handle->req_rp,reqbase->rb_fg);
  562.     UScoreText(handle->req_rp,text,x,y+font->tf_Baseline,-1);
  563.     if (handle->req_rp->cp_x<handle->req_width-2) {
  564.         SetAPen(handle->req_rp,reqbase->rb_bg);
  565.         RectFill(handle->req_rp,
  566.             handle->req_rp->cp_x,y,
  567.             handle->req_width-3,y+font->tf_YSize);
  568.     }
  569.     SetAPen(handle->req_rp,reqbase->rb_fg);
  570. }
  571.